package net.atos.spring;

import javax.annotation.Resource;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component("main")
public class Main {

    @Resource(name = "bookController")
    BookController controller;

    public static void main(String... args) {
	final ApplicationContext ctx = new GenericXmlApplicationContext("classpath:/META-INF/spring/app-context.xml");
	final Main bean = (Main) ctx.getBean("main");
	bean.go();
    }

    @Transactional
    public void go() {
	Book book = new Book(1L, "title", "author");
	controller.save(book);
    }
}
